package user

import (
	"context"
	"github.com/jinzhu/copier"
	"go.uber.org/zap"
	"navi-mumbai/app/api/business/internal/svc"
	"navi-mumbai/app/api/business/internal/types"
	"navi-mumbai/app/rpc/usercenter/pb"

	"github.com/zeromicro/go-zero/core/logx"
)

type QueryIncomeListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewQueryIncomeListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *QueryIncomeListLogic {
	return &QueryIncomeListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *QueryIncomeListLogic) QueryIncomeList(req *types.QueryIncomeListReq) (resp *types.QueryIncomeListResp, err error) {
	l.Logger.Infof("QueryIncomeList Uid %s ", req.Uid)
	var in pb.QueryIncomeListReq
	_ = copier.Copy(&in, req)
	var rsp *pb.QueryIncomeListResp
	rsp, err = l.svcCtx.UcUserRpc.QueryIncomeList(l.ctx, &in)
	l.Logger.Infof("QueryIncomeList. rsp: %+v", rsp)
	if err != nil {
		l.Logger.Errorf("err == ", zap.Error(err))
		return nil, err
	}
	l.Logger.Infof("QueryIncomeList：%+v", rsp)
	resp = &types.QueryIncomeListResp{
		List: make([]*types.Incomes, 0),
	}
	_ = copier.Copy(resp, rsp)
	return
}
